/**
 * @author haixuanwo
 * @email haixuanwo_clark@hotmail.com
 * @date 2021-03-25
 * @brief 用户管理类
 */

#ifndef USER_MANAGER_H
#define USER_MANAGER_H

#include "mysqlite.h"
#include <string>
#include <vector>

typedef struct{
    std::string name;   // 用户名
    std::string passwd; // 密码
    int administrator;  // 1管理员，0普通用户
}User_t;

class UserManager{
public:
    UserManager();
    bool add_user(std::string &name, std::string &passwd, int administrator);
    bool delete_user(std::string &name);
    bool select_user(std::string &name);
    bool change_user(std::string &name, std::string &passwd, int administrator);
    bool match_user(std::string &name, std::string *passwd = nullptr, User_t *matchedUser = nullptr);
    bool get_all_user();
    void show_all_user();
    ~UserManager();

private:
    std::vector<User_t> *v_user;
    mySqlite *userDB;
};

#endif

